#include "knobject_napi.h"
#include "dynamic_api.h"
#undef LOG_DOMAIN
#undef LOG_TAG
#define LOG_DOMAIN 0x0000
#define LOG_TAG "testTag"

static dynamic_ExportedSymbols *lib = dynamic_symbols();

napi_value kn_add(napi_env env, napi_callback_info info) {
    size_t argc = 2;
    napi_value args[2] = {nullptr};

    napi_get_cb_info(env, info, &argc, args , nullptr, nullptr);

    napi_valuetype valuetype0;
    napi_typeof(env, args[0], &valuetype0);

    napi_valuetype valuetype1;
    napi_typeof(env, args[1], &valuetype1);

    int value0;
    napi_get_value_int32(env, args[0], &value0);

    int value1;
    napi_get_value_int32(env, args[1], &value1);

    napi_value sum;
    int res = lib->kotlin.root.add(value0, value1);
    napi_create_int32(env, res, &sum);
    return sum;
}